package q775_isIdealPermutation;

public class Solution_2 {
    /*
    对于每个元素 nums[i] 都满足
    Math.abs(nums[i] - i) > 1
    仍然是检查是否有非局部倒置
     */
    public boolean isIdealPermutation(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            if (Math.abs(nums[i] - i) > 1) {
                return false;
            }
        }
        return true;
    }
}
